package com.resys.server.controller.staff;

import com.resys.entity.dto.TokenUserInfoDto;
import com.resys.entity.enums.ResponseCodeEnum;
import com.resys.entity.po.Roomstatuslog;
import com.resys.entity.query.RoomstatuslogQuery;
import com.resys.entity.vo.ResponseVO;
import com.resys.exception.BusinessException;
import com.resys.server.controller.ABaseController;
import com.resys.service.RoomstatuslogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController("worklogController")
@RequestMapping("/staff/worklog")
@Api(tags = "员工接口-工作日志管理")
public class WorklogController extends ABaseController {
    @Resource
    private RoomstatuslogService roomstatuslogService;
    @ApiOperation("查看个人工作日志")
    @GetMapping
    public ResponseVO list(){
        TokenUserInfoDto tokenUserInfoDto = getTokenUserInfo("staff");
        if(tokenUserInfoDto==null){
            throw new BusinessException(ResponseCodeEnum.CODE_901);
        }
        RoomstatuslogQuery log= new RoomstatuslogQuery();
        log.setChangedBy(tokenUserInfoDto.getUserId());
        List<Roomstatuslog> list = roomstatuslogService.findListByParam(log);
        return getSuccessResponseVO(list);
    }
}
